//
//  BFHomeController.m
//  beifang
//
//  Created by Apple on 17/4/12.
//  Copyright © 2017年 郭凯. All rights reserved.
//

#import "BFHomeController.h"
#import "BFDetailController.h"
#import "BFYeWuCell.h"
#import "BFYeWuHeadCell.h"
#import "BFYeWuFlowLayout.h"
#import "BFListViewController.h"
#import "BFFuncationController.h"

@interface BFHomeController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (strong, nonatomic) IBOutlet UICollectionView *headCollectionView;
@property (strong, nonatomic) IBOutlet UICollectionView *detailCollectionView;

@end

@implementation BFHomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"首页";
    self.headCollectionView.dataSource = self;
    self.headCollectionView.delegate = self;
    self.headCollectionView.collectionViewLayout = [[BFYeWuFlowLayout alloc]init];
    self.detailCollectionView.dataSource = self;

    self.detailCollectionView.delegate = self;
    [self.headCollectionView registerNib:[UINib nibWithNibName:@"BFYeWuHeadCell" bundle:nil] forCellWithReuseIdentifier:@"headCollectionView"];
    [self.detailCollectionView registerNib:[UINib nibWithNibName:@"BFYeWuCell" bundle:nil] forCellWithReuseIdentifier:@"detailCollectionView"];
    
    NSLog(@"screenWidth = %lf",screenWidth);
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if (collectionView==self.headCollectionView) {
        return 4;
    }else{
        return 9;
    }
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (collectionView==self.headCollectionView) {
        BFYeWuHeadCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"headCollectionView" forIndexPath:indexPath];
//        cell.backgroundColor = indexPath.row%2?[UIColor yellowColor]:[UIColor purpleColor];
        return cell;
    }else{
        BFYeWuCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"detailCollectionView" forIndexPath:indexPath];
//        cell.backgroundColor = indexPath.row%2?[UIColor yellowColor]:[UIColor purpleColor];
        return cell;
    }
}


-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if (collectionView==self.headCollectionView) {
        BFFuncationController *fvc = [[BFFuncationController alloc]init];
        [self.navigationController pushViewController:fvc animated:YES];
    }else{
        BFListViewController *vc = [[BFListViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}


@end
